#!/bin/bash

echo Create clear copy of released files
mkdir release
cp Ragima.exe release/
cp *.dll release/
cp *.config release/
cp license.txt release/
for f in `find Data User -type d | grep -v .svn`; do
  mkdir release/$f;
  cp $f/*.* release/$f;
done

version=`svnversion -n | sed -e 's/.*://'`
name='ragima-r'$version'.rar'

echo Archive release $version to $name
if [[ ! -d releases ]]; then mkdir releases; fi;
rar a -ep1 -inul -m5 -r releases/$name release/*

echo Removed release copy
rm -rf release

if [[ $1 = 'upload' ]]; then
echo Upload release $version to Nereal FTP
ftp ftp.nereal.ru <<end
prompt off
binary
cd public_html/files/cards/
lcd releases
mput $name
bye
end
fi
